export default{
	data(){
		return{
			//页面是否已加载
			isReady:false
		}
	},
	// #ifdef APP-PLUS
	onBackPress:function(event) {
		if (event.from === 'navigateBack') {  
			return false;  
		}
		if(getCurrentPages().length<2){
			 var main = plus.android.runtimeMainActivity();  
			    main.moveTaskToBack(false);
			//plus.runtime.quit();
		}
	},
	// #endif
	computed:{
		userInfo(){
			return this.$store.state.chat.userInfo
		},
		appReady(){
			return this.$store.state.app.appReady
		},
		isSocketOpen(){
			return this.$store.state.chat.isSocketOpen
		}
	},
	watch:{
		'appReady':function(value){
			if(value && !this.userInfo.id){
				uni.reLaunch({url: '/pages/login/index'});
			}
		},
		'isSocketOpen':function(value){
			if(value && !this.isReady){
				this.isReady=true
				if(this.init){
					this.init()	
				}
			}
		}
	},
	onLoad:function(e){
		if(this.isSocketOpen){
			this.isReady=true
			if(this.init){
				this.init()	
			}
		}
	},
	onShow:function(){
		if(this.appReady && !this.userInfo.id){
			uni.reLaunch({url: '/pages/login/index'});
		}
	},
	// #ifdef APP-PLUS
	onBackPress:function(event) {
		if (event.from === 'navigateBack') {  
			return false;  
		}
		if(getCurrentPages().length<2){
			 var main = plus.android.runtimeMainActivity();  
			    main.moveTaskToBack(false);
			//plus.runtime.quit();
		}
	},
	// #endif
}